<include file="/public/header" />

<style>
    .layui-card-body {
        padding-left: 0;
    }

    .layui-form-item .layui-input-inline {
        width: 220px;
    }
</style>

<div class="layui-fluid layui-bg-white">
    <form class="layui-form layui-form-fixed">
        <gt name="$data.id" value="0"><input type="text" name="id" value="{$data.id}" hidden=""></gt>
        <input type="text" name="materialid" value="{$materialid|default=0}" hidden="">
        <div class="layui-form-item">
            <label class="layui-form-label">{:__('原材料')}</label>
            <div class="layui-input-block">
                <input disabled value="{$material|default=''}" class="layui-input" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:__('供应商')}</label>
            <div class="layui-input-block">
                <select name="supplierid" lay-verify="required">
                    <option value="">{:__('选择供应商')}</option>
                    <foreach $supplier as $v>
                        <option value="{$v.id}" <if $data.supplierid==$v.id>selected</if>>{$v.title}({$v.phone})
                        </option>
                    </foreach>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:__('进货日期')}</label>
            <div class="layui-input-block">
                
                    <input name="dates" <if empty($data.dates)>value="{:date('Ymd')}"<else>value="{$data.dates}"</if> data-dateformat="yyyyMMdd" lay-datetime=""
                        data-datetype="date" placeholder="{:__('请输入进货日期')}" type="text" class="layui-input"
                        lay-verify="required" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:__('到货日期')}</label>
            <div class="layui-input-block">
                <input value="{$data.getdates}" name="getdates" data-dateformat="yyyyMMdd" lay-datetime="" data-datetype="date"
                    placeholder="{:__('请输入到货日期')}" type="text" class="layui-input" lay-verify="required" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:__('进货重量(KG)')}</label>
            <div class="layui-input-block">
                <input value="{$data.weight}" name="weight" placeholder="{:__('进货重量')}" type="number" class="layui-input"
                    lay-verify="required" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:__('每kg价格(元)')}</label>
            <div class="layui-input-block">
                <input value="{$data.price}" name="price" placeholder="{:__('请输入每kg价格')}" type="number" class="layui-input"
                    lay-verify="required" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">进货凭据</label>
            <div class="layui-input-block">
                <div class="layui-imagesbox">
                    <notempty name="$data['album']">
                        <volist name="$data['album']" id="vo">
                            <div class="layui-input-inline layui-uplpad-image">
                                <img src="{$vo.src}" lay-image-hover>
                                <input type="text" name="album[{$key}][src]" hidden value="{$vo.src}">
                                <input type="text" name="album[{$key}][title]" class="layui-input" value="{$vo.title}"
                                    placeholder="图片简介">
                                <span class="layui-badge layui-badge-red"
                                    onclick="layui.$(this).parent().remove();">删除</span>
                            </div>
                        </volist>
                    </notempty>
                    <div class="layui-input-inline layui-uplpad-image">
                        <div class="layui-upload-drag" lay-upload="album" data-type="multiple" data-accept="images"
                            data-size="102400">
                            <i class="layui-icon layui-icon-upload"></i>
                            <p>点击上传，或将文件拖拽到此处</p>
                            <div class="layui-hide"></div>
                        </div>
                        <input class="layui-upload-file" type="file" accept="" name="file">
                        <button type="button" class="layui-btn layui-btn-xs layui-btn-fluid" lay-choose="album"
                            data-type="multiple">
                            <i class="layui-icon layui-icon-windows"></i> 选择
                        </button>
                    </div>
                </div>
            </div>
        </div>
        <!-- <div class="layui-form-item">
            <label class="layui-form-label">{:__('进货负责人')}</label>
            <div class="layui-input-block">
                <input name="head"  placeholder="{:__('请输入配方负责人')}" type="text" class="layui-input"
                    lay-verify="required" />
            </div>
        </div> -->
        <!-- <div class="layui-form-item">
            <table class="layui-table" lay-skin="nob">
                <colgroup>
                    <col>
                    <col>
                    <col>
                    <col>
                </colgroup>
                <thead>
                    <tr>
                        <th>原材料</th>
                        <th width="80">进货重量(KG)</th>
                        <th>每kg价格(元)</th>
                        <th width="50">操作</th>
                    </tr>
                </thead>
                <tbody id="layui-material-content">
                </tbody>
            </table>
        </div>
        <button type="button" class="layui-btn layui-btn-normal layui-material-add">{:__('增加一行')}</button> -->
        <div class="layui-footer layui-form-item layui-center ">
            <button class="layui-btn layui-btn-primary" type="button" sa-event="closeDialog">取消</button>
            <button class="layui-btn layui-btn-normal" lay-filter="submitIframe" type="button" lay-submit>提交</button>
        </div>
    </form>
</div>
<include file="/public/footer" />
<include file="/public/static" />

<script>
    layui.use(['form', 'jquery', 'layedit', 'admin'], function () {
        var form = layui.form;
        var jquery = layui.jquery;
        var material = { $material| raw
    };
    // 增加一行
    jquery('.layui-material-add').on('click', function () {
        var trnumber = jquery('#layui-material-content tr').length;
        var html = '<tr>';
        html += '<td><select name="list[' + trnumber + '][material]" lay-search=""><option value="">可输入搜索<\/option>';
        layui.$.each(material, function (index, type) {
            html += '<option value="' + type.id + '">' + type.title + '</option>';
        });
        html += '<\/select><\/td>';
        html += '<td><input name="list[' + trnumber + '][size]" type="text" class="layui-input"  lay-verify="required" ><\/td>';
        html += '<td><input name="list[' + trnumber + '][price]" type="text" class="layui-input"  lay-verify="required" ><\/td>';
        html += '<td><button type="button" class="layui-btn layui-btn-primary layui-btn-sm"><i class="layui-icon layui-icon-delete"><\/i><\/button><\/td>';
        html += '<\/tr>';
        jquery('#layui-material-content').append(html);
        form.render();
    })
    // 删除签到数据
    jquery('body').on('click', '#layui-material-content .layui-btn', function () {
        jquery(this).parents('tr').remove();
    })
    });
</script>